<?php  

namespace App\Services;
use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest;
use Darabonba\OpenApi\Models\Config as AlibabaConfig;
use Log;

class ThirdsmsService
{
    // 发送短信操作
    public static function alibabaSendSms($phoneNumbers,$templateParam)
    {
        $config = new AlibabaConfig([
            // 您的AccessKey ID
            "accessKeyId" => "LTAI5tMXvRK6CdQ2V64kUuxH",
            // 您的AccessKey Secret
            "accessKeySecret" => "q5663E5TJnZtQsjCjntjWCTl60nGQc"
        ]);
        // 访问的域名
        $config->endpoint = "dysmsapi.aliyuncs.com";
        $client = new Dysmsapi($config);
        $sendSmsRequest = new SendSmsRequest([
            "phoneNumbers" => $phoneNumbers,
            "templateCode" => "SMS_249520168",
            "signName" => "天天外链",
            "templateParam" => $templateParam
        ]);
        // 复制代码运行请自行打印 API 的返回值
        $response = $client->sendSms($sendSmsRequest);
        $code = $response->body->code;
        $message = $response->body->message;
        if ($code == "OK") {
            return ["status"=>"success","message"=>""];
        } else {
            return ["status"=>"error","message"=>$message];
        }
    }

    // 发送短信操作
    public static function alibabaSendyxSms($phoneNumbers)
    {
        $config = new AlibabaConfig([
            // 您的AccessKey ID
            "accessKeyId" => "LTAI5tMXvRK6CdQ2V64kUuxH",
            // 您的AccessKey Secret
            "accessKeySecret" => "q5663E5TJnZtQsjCjntjWCTl60nGQc"
        ]);
        // 访问的域名
        $config->endpoint = "dysmsapi.aliyuncs.com";
        $client = new Dysmsapi($config);
        $sendSmsRequest = new SendSmsRequest([
            "phoneNumbers" => $phoneNumbers,
            "templateCode" => "SMS_462710367",
            "signName" => "摩尔企服",
            "templateParam" => ''
        ]);
        // 复制代码运行请自行打印 API 的返回值
        $response = $client->sendSms($sendSmsRequest);
        $code = $response->body->code;
        $message = $response->body->message;
        if ($code == "OK") {
            return ["status"=>"success","message"=>""];
        } else {
            return ["status"=>"error","message"=>$message];
        }
    }
}